package com.wc.alorithm_luogu.P2550;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/21 12:28
 * @description https://www.luogu.com.cn/problem/P2550
 * 彩票摇奖
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Main main = new Main();
        // 存放中奖号码
        int[] prizeNum = new int[7];
        // 几位人
        int n = sc.nextInt();
        for (int i = 0; i < 7; i++) {
            prizeNum[i] = sc.nextInt();
        }
        // 排序 方便二分查找
        Arrays.sort(prizeNum);
        // 存放答案
        int[] ans = new int[7];
        // 存放当前输入中奖数总和
        int curNum = 0;

        int prizeTotal = 0;
        while (n-- > 0) {
            prizeTotal = 0;
            for (int i = 0; i < 7; i++) {
                curNum = sc.nextInt();
                if (main.binarySearch(prizeNum, curNum)) {
                    prizeTotal++;
                }
            }
            if (prizeTotal == 0) {
                continue;
            }
            ans[7 - prizeTotal]++;
        }

        System.out.print(ans[0]);
        for (int i = 1; i < 7; i++) {
            System.out.print(" " + ans[i]);
        }
    }

    /**
     * 二分搜索
     *
     * @param array
     * @param num
     * @return
     */
    public boolean binarySearch(int[] array, int num) {
        int left = 0;
        int right = array.length - 1;

        int mid;
        while (left <= right) {
            mid = left + (right - left) / 2;
            if (array[mid] == num) {
                return true;
            } else if (array[mid] < num) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return false;
    }
}
